package de.tum.in.eist.poll.client.widgets.other;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Panel;
import de.tum.in.eist.poll.client.widgets.content.FeedbackUIFactory;
import de.tum.in.eist.poll.shared.Lecture;

/**
 * A ClickHandler for use in the FeedbackUI
 * @author aperture
 *
 */
public class LectureLinkClickHandler implements ClickHandler {
	private Lecture selectedLecture = null;
	private Panel targetWidget = null;

	public LectureLinkClickHandler(Lecture lecture, Panel targetWidget) {
		selectedLecture = lecture;
		this.targetWidget = targetWidget;
	}

	@Override
	public void onClick(ClickEvent event) {
				targetWidget.clear();
				targetWidget.add(createLectureView().createContent()
						.draw());
	}

	private FeedbackUIFactory createLectureView() {
		return new FeedbackUIFactory(selectedLecture);
	}

}
